﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using Ecommerce.Web.Code;

namespace Ecommerce.Web
{
    public partial class Contato : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void lbEnviar_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                StringBuilder sbFormulario = new StringBuilder();

                sbFormulario.AppendLine("===================================================");
                sbFormulario.AppendLine("FORMULÁRIO DE CONTATO");
                sbFormulario.AppendLine("===================================================");

                sbFormulario.Append("ASSUNTO: ");
                sbFormulario.Append(txtAssunto.Text);
                sbFormulario.AppendLine();

                sbFormulario.Append("NOME COMPRADOR: ");
                sbFormulario.Append(txtNomeComprador.Text);
                sbFormulario.AppendLine();

                sbFormulario.Append("EMAIL CONTATO: ");
                sbFormulario.Append(txtEmailContato.Text);
                sbFormulario.AppendLine();

                sbFormulario.Append("TELEFONE: ");
                sbFormulario.Append(txtDDD.Text);
                sbFormulario.Append(" - ");
                sbFormulario.Append(txtTelefone.Text);
                sbFormulario.AppendLine();

                sbFormulario.Append("CPF: ");
                sbFormulario.Append(txtCPF.Text);
                sbFormulario.AppendLine();
                sbFormulario.AppendLine();

                sbFormulario.Append("MENSAGEM: ");
                sbFormulario.Append(txtMensagem.Text);
                sbFormulario.AppendLine();

                new Model.Email().EnviaMensagemEmail("igor.santana@devsoftware.net", "Formulário de contato", sbFormulario.ToString());

                ClientScript.RegisterClientScriptBlock(this.GetType(), "alertaOK", "alert('Mensagem enviada com sucesso!')", true);
                Response.Redirect("contato.aspx");
            }
        }

        protected void lbLimpar_Click(object sender, EventArgs e)
        {
            Response.Redirect("contato.aspx");
        }
    }
}